package com.isdepci.project.factor.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.factor.domain.CarbonFactorInfo;
import com.isdepci.project.factor.service.ICarbonFactorInfoService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 碳排放因子数据库Controller
 *
 * @author isdepci
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/factor/carbonFactorInfo")
public class CarbonFactorInfoController extends BaseController {
    @Autowired
    private ICarbonFactorInfoService carbonFactorInfoService;

    /**
     * 查询碳排放因子数据库列表
     */
    @PreAuthorize("@ss.hasPermi('factor:carbonFactorInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarbonFactorInfo carbonFactorInfo) {
        startPage();
        List<CarbonFactorInfo> list = carbonFactorInfoService.selectCarbonFactorInfoList(carbonFactorInfo);
        return getDataTable(list);
    }

    /**
     * 获取碳排放因子数据库详细信息
     */
    @PreAuthorize("@ss.hasPermi('factor:carbonFactorInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(carbonFactorInfoService.selectCarbonFactorInfoById(id));
    }

    /**
     * 修改碳排放因子数据库
     */
    @PreAuthorize("@ss.hasPermi('factor:carbonFactorInfo:save')")
    @Log(title = "碳排放因子数据库", businessType = BusinessType.SAVE)
    @PutMapping
    public AjaxResult saveInfo(@RequestBody CarbonFactorInfo carbonFactorInfo) {
        return toAjax(carbonFactorInfoService.saveCarbonFactorInfo(carbonFactorInfo));
    }

    /**
     * 删除碳排放因子数据库
     */
    @PreAuthorize("@ss.hasPermi('factor:carbonFactorInfo:remove')")
    @Log(title = "碳排放因子数据库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(carbonFactorInfoService.deleteCarbonFactorInfoByIds(ids));
    }


}
